package me.ak.api;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class EventManager {
	
	public static boolean addListener(Object e) {
		try {
			Class<?> em = Class.forName("me.ak.event.EventManager");
			if (em != null) {
				Method m = em.getMethod("addListener", new Class<?>[]{Object.class});
				m.setAccessible(true);
				m.invoke(em, new Object[]{e});
				return true;
			}
		} catch (ClassNotFoundException e1) {
			e1.printStackTrace();
		} catch (SecurityException e1) {
			e1.printStackTrace();
		} catch (NoSuchMethodException e1) {
			e1.printStackTrace();
		} catch (IllegalArgumentException e1) {
			e1.printStackTrace();
		} catch (IllegalAccessException e1) {
			e1.printStackTrace();
		} catch (InvocationTargetException e1) {
			e1.printStackTrace();
		}
		return false;
	}
	
	public static void triggerEvent(Object ev) {
		try {
			Class<?> em = Class.forName("me.ak.event.EventManager");
			if (em != null) {
				Method m = em.getMethod("trigEvent", new Class<?>[]{Object.class});
				m.setAccessible(true);
				m.invoke(em, new Object[]{ev});
			}
		} catch (ClassNotFoundException e1) {
			e1.printStackTrace();
		} catch (SecurityException e1) {
			e1.printStackTrace();
		} catch (NoSuchMethodException e1) {
			e1.printStackTrace();
		} catch (IllegalArgumentException e1) {
			e1.printStackTrace();
		} catch (IllegalAccessException e1) {
			e1.printStackTrace();
		} catch (InvocationTargetException e1) {
			e1.printStackTrace();
		}
	}

}
